package com.jsong.linuo.string;

import java.util.Scanner;

/**
 * @Author: 黎诺
 * @CreateTime: 2025-04-30
 * @Description: 练习 -> 键盘录入一个字符串,统计字符串中的大写字母,小写字母,数字出现的次数(不考虑其他字符)
 */

public class String06 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int big = 0;
        int small = 0;
        int number = 0;

        System.out.println("请输入字符串:");
        String data = sc.next();
        char[] chars = data.toCharArray();
        for (int i = 0; i < data.length(); i++) {
            char num = chars[i];
            //统计大写字母
            //A-Z -> 65-90
            if (num >= 'A' && num <= 'Z') {
                big++;
            }

            //统计小写字母
            //a-z -> 97-122
            if (num >= 'a' && num <= 'z') {
                small++;
            }

            //统计数字
            //0-9 -> 48-57
            if (num >= '0' && num <= '9') {
                number++;
            }
        }

        //打印出结果
        System.out.println("大写字母有"+big+"个");
        System.out.println("小写字母有"+small+"个");
        System.out.println("数字有"+number+"个");
    }
}
